package com.lanou.elh.sysmanage.system_order.web.controller;

import com.lanou.elh.sysmanage.system_order.entity.Order;
import com.lanou.elh.sysmanage.system_order.service.impl.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderServiceImpl orderService;

//    显示全部
    @GetMapping("/list")
    public List<Order> orderShowAll(){
        List<Order> list = orderService.selectAll();
        return list;
    }
//    统计订单数
    @GetMapping("/count")
    public Integer orderCount(){
        return orderService.orderCount();
    }
//    取消订单
    @GetMapping("/cancel")
    public String orderCancel(Order order){
        orderService.orderCancelById(order);
        return null;
    }
//    删除订单
    @DeleteMapping("/del")
    public String orderDel(String[] ids){
        for (String id : ids) {
            orderService.orderDel(id);
        }
        return null;
    }
//    打印时获得详情
    @GetMapping("/detail")
    public List<Order> orderShow(String id){
        List<Order> order = orderService.orderSelectById(id);
//        System.out.println("controller层"+order);
        return order;
    }
//    添加备注
    @PostMapping("/remark")
    public String orderRemark(Order order){
        Integer test = orderService.remark(order);
        return null;
    }
//    发货信息
    @PostMapping("/deliver")
    public String orderDeliver(Order order){
        orderService.deliver(order);
        return null;
    }
}

